package cn.com.taiji.oospub.wechat.service.impl;

import cn.com.taiji.oospub.wechat.common.Finals;
import cn.com.taiji.oospub.wechat.entity.CourseType;
import cn.com.taiji.oospub.wechat.entity.MemberBaseInfo;
import cn.com.taiji.oospub.wechat.mapper.CourseTypeMapper;
import cn.com.taiji.oospub.wechat.service.ICourseTypeService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 菜品分类 服务实现类
 * </p>
 *
 * @author 
 * @since 2020-11-19
 */
@Service
public class CourseTypeServiceImpl extends ServiceImpl<CourseTypeMapper, CourseType> implements ICourseTypeService {

    @Autowired
    private CourseTypeMapper courseTypeMapper;

    @Override
    public List<CourseType> coursesTypelist(MemberBaseInfo member) {
        Finals.ZhOrEn zhOrEn = member.getZhOrEn();
        QueryWrapper<CourseType> queryWrapper = new QueryWrapper<>();
        queryWrapper.select("id","name_ch","name_en").eq("is_delete", false);
//        queryWrapper.eq("restaurant_id", member.getRestaurant().getId());
        queryWrapper.orderByAsc("id");
        List<CourseType> courseTypes = courseTypeMapper.selectList(queryWrapper);
        if ("中文".equals(zhOrEn.getValue())){
            for (CourseType courseType:courseTypes) {
                courseType.setName(courseType.getNameCh());
            }
        }else {
            for (CourseType courseType:courseTypes) {
                courseType.setName(courseType.getNameEn());
            }
        }
        return courseTypes;
    }
}
